{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "toc": true
   },
   "source": [
    "<h1>Table of Contents<span class=\"tocSkip\"></span></h1>\n",
    "<div class=\"toc\"><ul class=\"toc-item\"><li><span><a href=\"#import\" data-toc-modified-id=\"import-1\"><span class=\"toc-item-num\">1&nbsp;&nbsp;</span>import</a></span></li><li><span><a href=\"#data\" data-toc-modified-id=\"data-2\"><span class=\"toc-item-num\">2&nbsp;&nbsp;</span>data</a></span></li><li><span><a href=\"#model\" data-toc-modified-id=\"model-3\"><span class=\"toc-item-num\">3&nbsp;&nbsp;</span>model</a></span></li><li><span><a href=\"#cam\" data-toc-modified-id=\"cam-4\"><span class=\"toc-item-num\">4&nbsp;&nbsp;</span>cam</a></span></li></ul></div>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# import"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "from PIL import Image\n",
    "import cv2\n",
    "from pyvino.model.model import Model\n",
    "from pyvino.util.config import TASKS\n",
    "from pyvino.util.image import imshow, cam_test"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "#implemented tasks \n",
    "tasks = list(TASKS.keys())\n",
    "tasks"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# data\n",
    "- if input data is from camera, input_dat = 0\n",
    "- if input data is from file, input_data = path to file"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "#input_data = 0\n",
    "input_data = '../data/test/pedestrian.mp4'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# model"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "task = tasks[5]\n",
    "model = Model(task)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# cam"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "cap = cv2.VideoCapture(input_data)\n",
    "cap.set(3, 640)\n",
    "cap.set(4, 480)\n",
    "while True:\n",
    "    ret, frame = cap.read()\n",
    "    if not ret:\n",
    "        break\n",
    "    \n",
    "    frame = np.array(frame)\n",
    "\n",
    "    ############################\n",
    "    frame = model.compute(frame)\n",
    "    ############################\n",
    "\n",
    "    cv2.imshow('demo', frame)\n",
    "    if cv2.waitKey(1) & 0xFF == ord('q'):\n",
    "        break\n",
    "\n",
    "cap.release()\n",
    "cv2.destroyAllWindows()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Environment (conda_pyvino)",
   "language": "python",
   "name": "conda_pyvino"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": true,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": true
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
